# Register your models here.
from django.contrib import admin

from .models import Team, TeamDetail, TeamMemberShip, MemberTraining, MemberTrainingRecord


class TeamMemberShipInline(admin.TabularInline):
    model = TeamMemberShip
    extra = 1


class TeamDetailAdmin(admin.ModelAdmin):
    inlines = [TeamMemberShipInline]
    list_display = ('team', 'avatar', 'announcement')
    search_fields = ('team__name',)


admin.site.register(Team)
admin.site.register(TeamDetail, TeamDetailAdmin)
admin.site.register(TeamMemberShip)


class MemberTrainingRecordInline(admin.TabularInline):
    model = MemberTrainingRecord
    extra = 1


class MemberTrainingAdmin(admin.ModelAdmin):
    inlines = [MemberTrainingRecordInline]
    list_display = ('name', 'team', 'training_type', 'start_time', 'end_time')
    search_fields = ('name', 'team__name')


admin.site.register(MemberTraining, MemberTrainingAdmin)
admin.site.register(MemberTrainingRecord)